<div style="width: 60%;float: left;">
    <div class="formTable" id="formTable">        
        <form action="/admini/managestore/instore" method="post">            
            <table style="width:60%" border="1">
                <tr>
                    <th nowrap>物流单号：</th>
                    <td  nowrap>
                        <input type="text" id="logistics" name="logistics" style="width:143px" value="<?php if ($this->ingstoreItem) echo $this->ingstoreItem->shipNo?$this->ingstoreItem->shipNo:$this->ingstoreItem->logisticsNo; ?>" />
                    </td>
                    <th nowrap>物流公司：</th>
                    <td colspan="5" nowrap>
                        <input type="text" id="logisticName" name="logisticName" style="width:143px" value="<?php if ($this->ingstoreItem) echo $this->ingstoreItem->shipType?$this->ingstoreItem->shipType:($this->ingstoreItem->logname?$this->ingstoreItem->logname->name:""); ?>" />
                    </td>
                    <td rowspan="9" nowrap width="300px">
                        <?= $this->formHidden('image', '/pic/wu40.png') ?>
                        <div class="fieldset flash" id="fsUploadProgress">
                            <span class="legend">Upload Queue</span>
                        </div>
                        <div id="divStatus">0 Files Uploaded</div>
                        <div>
                            <span id="stt"></span></br>
                            <input id="btnCancel" type="button" value="Cancel All Uploads" onclick="swfu.cancelQueue();" disabled="disabled" style="margin-left: 2px; font-size: 8pt; height: 29px;" />
                        </div>
                        <div style="position: absolute;margin-left:120px;margin-top:-100px">
                            <image id="pimage" src="/pic/wu40.png" />
                        </div>
                    </td>
                </tr>

                <tr>
                    <th nowrap>包裹类型：</th>
                    <td nowrap>
                        <input type="text" id="intype" name="intype" value="<?php echo ($this->ingstoreItem)?$this->ingstoreItem->PayDescription:"自助包裹";?>" readonly />
                    </td>
                    <th nowrap>国内运费：</th>
                    <td colspan="3" >
                        <input type="text" id="cnShipFee" name="cnShipFee" style="width:143px" value="" />
                    </td>
                </tr>

                <tr>
                    <th width="100px" class="w1" nowrap>仓库号：</th>
                    <td width="180px" nowrap>
                        <input type="hidden" id="ingstoreId" name="ingstoreId" value="<?php if ($this->ingstoreItem) echo $this->ingstoreItem->id; ?>" />
                        <input type="text" id="storeno" name="storeno" style="width:143px" value="<?php if($this->ingstoreItem){echo $this->ingstoreItem->userinfo->storeno;} ?>" />
                    </td>

                    <th width="100px" nowrap>预报序号：</th>
                    <td nowrap colspan="3">
                        <input type="text"  value="<?php if ($this->ingstoreItem) echo $this->ingstoreItem->id; else echo '0'; ?>" id="storeId" name="storeId" style="width:143px" />
                    </td>
                </tr>

                <tr>
                    <th nowrap>用户信息：</th>
                    <td colspan="5" nowrap>
                        <?php
                        if ($this->ingstoreItem) {
                            ?>
                            <span style="color:#000000" id="userinfo">帐号:<?php echo $this->ingstoreItem->userinfo->email; ?> 用户ID：<?php echo $this->ingstoreItem->userinfo->id; ?> 昵称:<?php echo $this->ingstoreItem->userinfo->nikename; ?></span>
                            <input type="hidden" id="userid" name="userid" value="<?php echo $this->ingstoreItem->userid?$this->ingstoreItem->userid:$this->ingstoreItem->userId; ?>"/>
                            <?php
                        } else {
                            ?>
                            <span style="color:#000000" id="userinfo">输入仓库号，将会自动加载用户信息</span>
                            <input type="hidden" id="userid" name="userid" value=""/>
                            <?php
                        }
                        ?>
                    </td>
                </tr>
                <?php $bcode = date("ymd") . substr(time(), -5, 5); ?>
                <tr>
                    <th nowrap>仓库条形码：</th>
                    <td colspan="5" nowrap>
                        <input type="text" id="barcode" name="barcode" style="width:143px" value="<?php echo $bcode;?>" />
                    </td>
                </tr>

                <tr>
                    <th nowrap>物品重量：</th>
                    <td nowrap>
                        <input type="text" id="weight" name="weight" style="width:143px" />
                    </td>

                    <th nowrap>去包重量：</th>
                    <td nowrap>
                        <input type="text" id="noPackageWeight" name="noPackageWeight" style="width:50px" />
                    </td>

                    <th nowrap>真空后体积重量：</th>
                    <td nowrap>
                        <input type="text" id="vacuumWeight" name="vacuumWeight" style="width:50px" />
                    </td>
                </tr>

                <tr>
                    <th nowrap>体积：</th>
                    <td nowrap>
                        <input type="text" id="length" value="0" name="length" style="width:40px" />*<input type="text" value="0" id="width" name="width" style="width:40px" />*<input type="text" id="height" value="0" name="height" style="width:40px" />
                    </td>

                    <th nowrap>体积重量：</th>
                    <td nowrap>
                        <input type="text" id="volumeWeight" value="0" name="volumeWeight" style="width:50px" />
                    </td>

                    <th nowrap>体积重量类型：</th>
                    <td nowrap>
                        <select id="bignessType" name="bignessType">
                            <option value="0" selected>普通</option>
                            <option value="1">轻抛</option>
                            <option value="2">抛</option>
                            <option value="3">重抛</option>
                        </select>
                    </td>
                </tr>



                <tr>
                    <th nowrap>&nbsp;</th>
                    <td colspan="5" nowrap><label> <?= $this->formCheckbox('isPack') ?>是否有包装</label>&nbsp;&nbsp;<label> <?= $this->formCheckbox('canVacuum') ?>能否真空处理</label>&nbsp;&nbsp;<label> <?= $this->formCheckbox('isEmbargo') ?>是否禁运品</label>&nbsp;&nbsp;<label> <?= $this->formCheckbox('isSpecific') ?>是否特殊的</label></td>
                </tr>

                <tr>
                    <th nowrap>产品类型：</th>
                    <td colspan="5" nowrap nowrap><ul clas="itemtype">
                            <li><label><input type="checkbox" name="itemType[]" id="itemType" value="1">仿牌</label></li>
                            <li><label><input type="checkbox" name="itemType[]" id="itemType" value="2">电池</label></li>
                            <li><label><input type="checkbox" name="itemType[]" id="itemType" value="4">液体</label></li>
                            <li><label><input type="checkbox" name="itemType[]" id="itemType" value="8">食品</label></li>
                            <li><label><input type="checkbox" name="itemType[]" id="itemType" value="16">粉未</label></li>                        
                            <li><label><input type="checkbox" name="itemType[]" id="itemType" value="32">膏状物</label></li>                        
                            <li><label><input type="checkbox" name="itemType[]" id="itemType" value="64">药物</label></li>                        
                            <li><label><input type="checkbox" name="itemType[]" id="itemType" value="128">敏感</label></li> 
                            <li><label><input type="checkbox" name="itemType[]" id="itemType" value="0" checked>正常</label></li>  
                        </ul>
                    </td>                      
                    <td></td>
                </tr>

                <tr>
                    <th nowrap>包裹名称：</th>
                    <td colspan="6" nowrap>
                        <input type="text" name="productName" id="productName" style="width:99%" value ="<?php if ($this->ingstoreItem) echo $this->ingstoreItem->name?$this->ingstoreItem->name:''; ?>">
                    </td>
                </tr>  

                <tr height="2px">
                    <th>&nbsp;</th>
                    <td colspan="6">
                        &nbsp;
                    </td>
                </tr> 

                <tr>
                    <th nowrap>包裹清单：</th>
                    <td colspan="6">
                        <textarea name="remark" id="remark" style="margin: 15px 0px 0px; width: 99%; height: 144px;text-align: left;"><?php if ($this->ingstoreItem){ 
                                if($this->ingstoreItem->remark){
                                    echo $this->ingstoreItem->remark; 
                                }else{
                                    if($this->ingstoreItem->shipdetail){
                                        foreach ($this->ingstoreItem->shipdetail as $key => $val) { 
                                            echo ($key+1)."、".$val->productName."\n";
                                        }
                                    }
                                }
                            }?>
                        </textarea>
                    </td>
                </tr>
            </table>
            <div>
                <input type="submit" onclick="return checkForm();" value="确认入库">                
            </div>
        </form>
    </div>
</div>
<div style="width:280px;float: left;margin-top: -10px;" id="printform">
    <script type="text/javascript" src="/admins/js/jquery/jquery.PrintArea.js"></script>
    <div id="printadd" style="width:280px;text-align: center;">
        <style>
        body{
            -webkit-print-color-adjust: exact;
        }
        </style>
        <div style='margin-bottom: 10px;width:250px;margin-left: 35px;margin-top: -5px;'>
            <div style="width:30px;float:left;margin-bottom: 10px;margin-top: -10px;">&nbsp;</div>
            <div style="width:200px;float:left;text-align: left;font-size: 12px;font-family: Microsoft yahei;margin-top: -8px;">悠奇个人云仓库
                <div id="loginstoreno" style="margin-right:50px;text-align:right;float:right;width:50px;font-size:14px;font-weight:900;"><?php if ($this->ingstoreItem) {echo $this->ingstoreItem->userinfo->storeno;}else{echo "&nbsp;";} ?>
                </div></div>
        </div>
        <div style='margin-bottom: 10px;width:280px;margin-left: 5px;float:left;'>
            <div style="width:30px;float:left;">&nbsp;</div>
            <div style="width:210px;float:left;text-align: center;"><img src="/barcode/barcode.php?codebar=BCGcode128&text=<?php echo $bcode;?>" alt="barcode" width="150px" height="60px" style="margin-left:2px"/></div>
        </div>
    </div>
    <div id="printstore" <?php  if($this->countstore == 0){?> style="display: block;" <?php }else{echo 'style="display: none;"';}?>>
        <style>
        body{
            -webkit-print-color-adjust: exact;
        }
        #printstore{
            width:280px;text-align: center;float: left;
        }
        </style>
        <div style="width:65px;float:left;margin-bottom: 10px;">&nbsp;</div>
        <div style='margin-top: 10px;width:100px;float:left;text-align: left;font-size:12px;' id="loginname"></div>
        <div style="margin-top: 10px;text-align:right;float:left;width:50px;font-size:12px;" id="dq"></div>
        <div style='width:180px;text-align: center;font-size:48px;font-weight:900;margin-left: 50px;font-family:Arial;' id="loginstoreno"></div>
    </div>
    <div style="margin-left: 120px;width: 250px;float: left;margin-top: 20px" id="scbcode">
        <input type="button" id="printcode" naem="printcode" value="打印条形码" style="background-color: #FF8312;width: 80px;height: 30px;color: white;font-size: 14px;border-radius:8px;margin-left: 20px;"/>
        <input type="button" id="printstore" naem="printcode" value="打印仓库号" style="background-color: #FF8312;width: 80px;height: 30px;color: white;font-size: 14px;border-radius:8px;margin-left: 20px;"/>
    </div>
    <script type="text/javascript" >
        $('#scbcode #printcode').click(function(){
            $("div#printform div#printadd").printArea(); 
        });
        $('#scbcode #printstore').click(function(){
            $("div#printform div#printstore").printArea(); 
        });
    </script>
</div>
<div style="width: 800px;float: left;" id="dgxx">
    <?php if($this->ingstoreItem){
        if($this->ingstoreItem->userId){
        $orderItem = $this->ingstoreItem->shipdetail;
        ?>
        <table border="1" cellpadding="0" cellspacing="0" style="margin-left:30px;width:100%;font-size:14px;">
            <tr>
                <td style="padding:5px;width:370px;text-align:center;">商品信息</td><td style="width:80px;text-align:center;">商品单价(￥)<br>状态</td>
                <td style="padding:5px;width:50px;text-align:center;">数量</td><td style="width:100px;text-align:center;">实付款(￥)</td>
            </tr>
            <tr>
                <td style="padding:5px;" colspan="4">
                    <span style="margin-left:20px;">代购单号：<?php echo $this->ingstoreItem->id;?></span>
                    <span style="margin-left:20px;">提交时间：<?php echo $this->ingstoreItem->dateCreated;?></span></td>
            </tr>
            <?php foreach ($orderItem as $key1 => $ordervalue) {
                $productd = $ordervalue->byproductd;
                ?>
                <tr>
                    <td style="padding: 5px;" valign="middle">
                        <div style="float:left;">
                            <a href="<?php echo $productd->url;?>" target="_blank"><img src="<?php echo $productd->remoteImage;?>" width="50px" height="50px" style="vertical-align:middle;"/></a>
                       </div>
                       <div>&nbsp;&nbsp;<a href="<?php echo Application_Model_OrderItem::GetTopUrl($productd, $ordervalue);?>" target="_blank" >
                           <?php echo iconv_strlen($ordervalue->productName)>=50?mb_substr($ordervalue->productName,0,50, 'utf-8').'...':$ordervalue->productName;?></a></div><br>
                        <div style="float:left;color:#666;">&nbsp;&nbsp;<?php echo iconv_strlen($productd->PropertyAlias)>=50?mb_substr($productd->PropertyAlias,0,50, 'utf-8').'...':$productd->PropertyAlias;?></div></td>
                    <td align="center">
                        <?php echo $ordervalue->price;?><br><?php echo $ordervalue->status == 1?'<span style="color:red">已退款</span>':'正常';?>
                    </td>
                    <td align="center"><?php echo $ordervalue->quantity;?></td>
                    <?php if($key1 == 0){ ?>
                            <td align="center" rowspan="<?php echo count($orderItem);?>"><?php echo $this->ingstoreItem->sum;echo $this->ingstoreItem->shipFee>0?"<br>含运费：$this->ingstoreItem->shipFee":"";?></td>
                    <?php }?>
                </tr>
            <?php }?>
        </table>
    <?php }}?>
    &nbsp;&nbsp;
</div>
<script type="text/javascript" src="http://demo.swfupload.org/v220/swfupload/swfupload.js"></script>
<script type="text/javascript" src="http://demo.swfupload.org/v220/simpledemo/js/swfupload.queue.js"></script>
<script type="text/javascript" src="http://demo.swfupload.org/v220/simpledemo/js/handlers.js"></script>
<script type="text/javascript" src="http://demo.swfupload.org/v220/simpledemo/js/fileprogress.js"></script>

<script>
    $(function(){
        $('#storeno').change(function(){
            var storeno = $(this).val();
            $.post('/admini/managestore/userinfo', {'storeno':storeno}, function(data){
                if(!data){
                    $('#userinfo').text('没有找到该仓库号对应的用户信息');
                    alert('没有找到该仓库号对应的用户信息,请检查仓库号是否输入正确');
                    $('#storeno').focus();
                    return;
                }
                $('#userid').val(data.userid);
                $('div#loginstoreno').text(storeno.toUpperCase());
                $('div#loginname').text(data.nikeName);
                $('div#dq').text(data.dq);
                if(data.countstore == 0){
                    $('#printstore').attr('style','display:blcok');
                }else{
                    $('#printstore').attr('style','display:none');
                }
                $('#userinfo').text('帐号:'+data.email+' 用户ID：'+data.userid+' 昵称:'+data.nikeName);
            }, 'json');
        });
        $("#logistics").change(function(){
            $.post('/admini/managestore/logisticsinfo', {'shipNo':$(this).val()}, function(data){
                if(!data){
                    $('#userid').val('');
                    $('#userinfo').text('');
                    $('#storeno').val('');
                    $('#logisticName').val('');
                    $('#productName').val('');
                    $('#remark').val('');
                    $('#intype').val("自助包裹");
                    return;
                }
                /**
                 * 加载包裹住处
                 */
                $('#userid').val(data.userid);
                $('#userinfo').text('帐号:'+data.email+' 用户ID：'+data.userid+' 昵称:'+data.nikeName);
                $('#storeno').val(data.storeno);
                $('#logisticName').val(data.shipType);
                $('#productName').val(data.name);
                $('#remark').val(data.remark);
                $('#intype').val(data.intype);
                $('#storeId').val(data.storeid);
                $("#ingstoreId").val(data.storeid);
                $('div#loginstoreno').text(data.storeno);
                $('div#loginname').text(data.nikeName);
                $('div#dq').text(data.dq);
                $("#dgxx").html("");
                if(data.intype == "代购订单"){
                    var html = '<table border="1" cellpadding="0" cellspacing="0" style="margin-left:30px;width:100%;font-size:14px;">';
                    html+= '<tr><td style="padding:5px;width:370px;text-align:center;">商品信息</td><td style="width:80px;text-align:center;">商品单价(￥)<br>状态</td>';
                    html+= '<td style="padding:5px;width:50px;text-align:center;">数量</td><td style="width:100px;text-align:center;">实付款(￥)</td></tr>';
                    html+= '<tr><td style="padding:5px;" colspan="4"><span style="margin-left:20px;">代购单号：'+data.id+'</span><span style="margin-left:20px;">提交时间：'+data.dateCreated+'</span></td></tr>';
                    $.each(data.orderItem, function(key, val) {
                        html+= '<tr><td style="padding: 5px;" valign="middle"><div style="float:left;">';
                        html+= '<a href="'+val.url+'" target="_blank"><img src="'+val.remoteImage+'" width="50px" height="50px" style="vertical-align:middle;"/></a>';
                        html+= '</div>&nbsp;&nbsp;<div style="float:left;"><a href="'+val.tgurl+'" target="_blank" >'+val.productName+'</a></div><br>';
                        html+= '<div style="float:left;color:#666;">&nbsp;&nbsp;'+val.PropertyAlias+'</div></td><td align="center">'+val.price+'<br>';
                        if(val.status == 1){
                            html+='<span style="color:red">已退款</span>';
                        }else{
                            html+= '正常';
                        }
                        html+= '</td>';
                        html+= '<td align="center">'+val.quantity+'</td>';
                        if(key == 0){
                            html+= '<td align="center" rowspan="'+data.num+'">'+data.sum;
                            if(data.shipFee>0){
                                html+= '<br>含运费：'+data.shipFee;
                            }
                            html+= '</td>';
                        }
                        html+= '</tr>';
                    });
                    html+= "</table>";
                    $("#dgxx").html(html);
                    
                }
                if(data.countstore == 0){
                    $('#printstore').attr('style','display:blcok');
                }else{
                    $('#printstore').attr('style','display:none');
                }
            }, 'json');
        });
        
        $('form').validate();
        
        $('#length,#width,#height,#weight').change(function(){
            var length = parseFloat($('#length').val());
            if(typeof(length) == 'NaN')
                length = 0;
            var width = parseFloat($('#width').val());
            if(typeof(width) == 'NaN')
                width = 0;
            var height = parseFloat($('#height').val());
            if(typeof(height) == 'NaN')
                height = 0;

            $('#volumeWeight').val(length*width*height/5);
            
            var weight = parseFloat($('#weight').val());
            var volumeWeight = parseFloat($('#volumeWeight').val());
            var volumeWeightSelected = parseFloat(volumeWeight/weight);
            
            if(volumeWeightSelected <= 1)
            {
                $("#bignessType").attr("value",'0');
            }
            else if(volumeWeightSelected > 1 && volumeWeightSelected <= 1.3)
            {
                $("#bignessType").attr("value",'1');
            }
            else if(volumeWeightSelected > 1.3 && volumeWeightSelected <= 1.6)
            {
                 $("#bignessType").attr("value",'2');       
            }
            else if(volumeWeightSelected > 1.6)
            {   
                 $("#bignessType").attr("value",'3');
            }  
        });
          
        $('form').validate();
    });
    
    function checkForm(){
        if($('#storeno').val() == ""){
            alert("请输入仓库号");
            return false;
        }
        
        if($('#userid').val() == ""){
            alert("用户不存在，请输入正确的仓库号");
            return false;
        }
  
        if($.trim($('#weight').val()) == ""){
            alert("物品重量不能为空");
            return false;
        }
        
        if($.trim($('#productName').val()) == ""){
            alert("请输入包裹清单");
            return false;
        }
        
        return true;
    }
</script>
<script type="text/javascript">
    var swfu;

    window.onload = function() {
        var settings = {
            flash_url : "/js/swfupload/swfupload.swf",
            upload_url: "/ajax/upload",
            post_params: {"PHPSESSID" : ""},
            file_size_limit : "100 MB",
            file_types : "*.jpeg;*.png;*.jpg;*.gif",
            file_types_description : "图片文件",
            file_upload_limit : 100,
            file_queue_limit : 0,
            custom_settings : {
                progressTarget : "fsUploadProgress",
                cancelButtonId : "btnCancel"
            },
            debug: false,

            // Button settings
            button_image_url: "/images/share/button.gif",
            button_width: "65",
            button_height: "29",
            button_placeholder_id: "stt",
            button_text: '<span class="theFont">上传图片</span>',
            button_text_style: ".theFont { font-size: 16; }",
            button_text_left_padding: 12,
            button_text_top_padding: 3,
				
            // The event handler functions are defined in handlers.js
            file_queued_handler : fileQueued,
            file_queue_error_handler : fileQueueError,
            file_dialog_complete_handler : fileDialogComplete,
            upload_start_handler : uploadStart,
            upload_progress_handler : uploadProgress,
            upload_error_handler : uploadError,
            upload_success_handler : function(file,data){
                $('#image').val($.parseJSON(data));
                $('#pimage').attr('src',$('#image').val());
                var progress = new FileProgress(file, this.customSettings.progressTarget);
                progress.setComplete();
                progress.setStatus("Complete.");
                progress.toggleCancel(false);
            },
            //upload_success_handler : uploadSuccess,
            upload_complete_handler : uploadComplete,
            queue_complete_handler : queueComplete	// Queue plugin event
        };

        swfu = new SWFUpload(settings);
    };
</script>